<template>
	<div class="front">
		<div class="table table-auto bg-white bj">
            <el-scrollbar style="height: 100%;">
                <el-table :data="tableData" border ref="table" highlight-current-row @row-dblclick="dbRowClick" style="width: 100%">
                    <el-table-column label="类别代码" type="index" width="289" :index="indexMethod" align="center"></el-table-column>
                    <el-table-column property="name" label="类别名称" width="290" align="center"></el-table-column>
                </el-table>
            </el-scrollbar>
        </div>
	</div>
</template>
<script>
export default {
	data() {
		return {
			tableData: []
		}
	},
	methods: {
		getTableData() {		//获取表格数据
			this.$http.get('accountItem/select').then(res => {
				if(res.data.code == 20001) {
					if(res.data.data) {
                        this.tableData = res.data.data[0]['accountItems'];
                    }
				}
			});
		},
		dbRowClick(row) {		//双击选中
			this.$store.commit('accountSubjectStore/updateBetweenObject', row);			//选择会计科目
			this.close();
		},
		indexMethod(index) {	//自定义索引值
			return '00' + (index + 1);
		},
		close() {
			let index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
		}
	},
	created() {
		this.getTableData();
	}
}
</script>